package ar.edu.uba.fi.jmit.graphvisualizer.server.storage;

import java.io.Serializable;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import junit.framework.TestCase;

public class MethodTimeDataStorageTestCase extends TestCase {

	public void test() {
		DataStorage storage = new DataStorage();
		storage.addData(this.createMap("Application1", "Monitor1", new Date()));
		storage.addData(this.createMap("Application1", "Monitor2", new Date()));
		storage.addData(this.createMap("Application2", "Monitor1", new Date()));
		storage.addData(this.createMap("Application2", "Monitor1", new Date()));
		storage.addData(this.createMap("Application2", "Monitor2", new Date()));
		
		assertEquals(1, storage.getData("Application1", "Monitor1").size());
		assertEquals(1, storage.getData("Application1", "Monitor2").size());
		assertEquals(2, storage.getData("Application2", "Monitor1").size());
		assertEquals(1, storage.getData("Application2", "Monitor2").size());
	}

	private Map<String, Serializable> createMap(String applicationName, String monitorName,
			Date date) {
		Map<String, Serializable> map = new HashMap<String, Serializable>();
		map.put("client_application", applicationName);
		map.put("monitor_name", monitorName);
		map.put("date", date);
		map.put("someOtherString", "Some Value");
		map.put("anInteger", 1);
		return map;
	}
}

